package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.ArtisanEarings;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface ArtisanEaringsMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(ArtisanEarings record);

    int insertSelective(ArtisanEarings record);

    ArtisanEarings selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(ArtisanEarings record);

    int updateByPrimaryKey(ArtisanEarings record);

    List<Map<String, Object>> getArtisanEaringsByArtisanId(@Param("artisanId") String artisanId,
                                                           @Param("start") Integer start,
                                                           @Param("end") Integer size,
                                                           @Param("startTime") String startTime,
                                                           @Param("endTime") String endTime);

    Integer getArtisanEaringsByArtisanIdAmount(@Param("artisanId") String artisanId,
                                               @Param("startTime") String startTime,
                                               @Param("endTime") String endTime);

    Integer getArtisanMoney(@Param("artisanId") String artisanId,
                            @Param("startTime") String startTime,
                            @Param("endTime") String endTime);

    List<Map<String, Object>> getCanCashMoney();

    //修改已超过更改需求时效订单状态为1
    @Update("UPDATE c_artisan_earings SET money_status = '1'  " +
            "WHERE demand_id IN " +
            "( SELECT a.demand_id FROM " +
            "( SELECT ea.demand_id FROM c_artisan_earings ea " +
            "WHERE DATE_ADD( ea.create_time, INTERVAL 7 DAY) < now( ) ) a )")
    int updateStatus();

    List<Map<String, Object>> getMyIncomesList(@Param("artisanId") String artisanId);
}